﻿/*
 * Vytvořeno aplikací SharpDevelop.
 * Uživatel: hanni
 * Datum: 13.4.2008
 * Čas: 10:03
 * 
    .-. .-.  .--.  .-. .-..-. .-..-.   .-.
    | | | | / /\ \ |  \| ||  \| | \ \_/ )/
    | `-' |/ /__\ \|   | ||   | |  \   (_)
    | .-. ||  __  || |\  || |\  |   ) (
    | | |)|| |  |)|| | |)|| | |)|   | |
    /(  (_)|_|  (_)/(  (_)/(  (_)  /(_|
   (__)           (__)   (__)     (__)
 */

using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace ISY.Server.GUI.Controls
{
	/// <summary>
	/// Description of ClientDetailView.
	/// </summary>
	public partial class ClientDetailView : UserControl
	{
		public ClientDetailView()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
		}
		public string MachineName
		{
			get{
				return this.SelectedClientInfo.MachineName;
			}
			private set{
				this.lblMachineName.Text = "Jméno počítače:" + value;
			}
		}
		public string UserDomainName
		{
			get{
				return this.SelectedClientInfo.UserDomainName;
			}
			private set{
				this.lblUserDomain.Text = "Jméno počítače v síti:" + value;
			}
		}
		public string OSVersion {
			get { return this.SelectedClientInfo.OSVersion; }
			private set { 
				this.lblOSVersion.Text = "Verze OS:" + value;
			}
		}
		public string UserName {
			get { return this.SelectedClientInfo.UserName; }
			private set { 
				this.lblUserName.Text = "Přihlašovací jméno aktuálního uživatele:" + value;
			}
		}
		
		public Image Screenshot
		{
			get
			{
				return this.pictureScreenshot.Image;
			}
			set
			{
				this.pictureScreenshot.Image = value;
			}
		}
		
		ClientInfo _selectedClientInfo = null;
		
		public ClientInfo SelectedClientInfo {
			get { return _selectedClientInfo; }
			set {
				_selectedClientInfo = value; 
				if(value != null)
				{
					this.groupPrikazy.Enabled = false;
					this.setLabels(value);
				}
			}
		}
		
		void setLabels(ClientInfo value)
		{
			this.MachineName = value.MachineName;
			this.UserDomainName = value.UserDomainName;
			this.OSVersion = value.OSVersion;
			this.UserName = value.UserName;
		}
		
		void LinkShutdownLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			if(this.SelectedClientInfo != null)
			{
				this.SelectedClientInfo.Shutdown();
			}
		}
		
		void LinkRestartLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			if(this.SelectedClientInfo != null)
			{
				this.SelectedClientInfo.Restart();
			}
		}
		
		void LinkLogOffLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			if(this.SelectedClientInfo != null)
			{
				this.SelectedClientInfo.LogOff();
			}
		}
		
		void LinkUpdateLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			if(this.SelectedClientInfo != null)
			{
				this.SelectedClientInfo.UpdateInfo();
				this.setLabels(this.SelectedClientInfo);
			}
		}
	}
}
